using TodoPro.System.Event;

namespace TodoPro.System.Command
{
    public class RemoveTodoCommand : ITodoCommand
    {
        private readonly string mTodoId;

        public RemoveTodoCommand(string todoId)
        {
            mTodoId = todoId;
        }

        /// <summary>
        /// 执行
        /// </summary>
        public void Execute()
        {
            var todoRepository = TodoProConfig.GetModel<ITodoModel>();

            todoRepository.Remove(mTodoId);
            
            TodoProConfig.SendEvent(new OnTodoRemoveEvent()
            {
                TodoId = mTodoId
            });
        }
    }
}